<template>
  <Layout>
    <div class="tags">
      <div class="defaultTags">
        <h3>默认标签</h3>
        <default-tags />
      </div>
      <div class="myTags">
        <h3>自定义标签</h3>
        <router-link
          class="tag"
          v-for="tag in myTags"
          :key="tag.id"
          :to="`/labels/edit/${tag.id}`"
        >
          <span>
            <Icon name="ordinary" />
            {{ tag.name }}
          </span>
          <Icon name="right" />
        </router-link>
      </div>
    </div>
    <div class="createTag-wrapper">
      <Icon name="addTo" @click="createTag" />
    </div>
  </Layout>
</template>

<script lang="ts">
import { Component } from 'vue-property-decorator'
import { mixins } from 'vue-class-component'
import TagHelper from '@/mixins/TagHelper'
import DefaultTags from '@/components/DefaultTags.vue'

@Component({
  components: { DefaultTags }
})
export default class Labels extends mixins(TagHelper) {
  get myTags() {
    return this.$store.state.tagList.slice(7)
  }

  beforeCreate() {
    this.$store.commit('fetchTags')
  }
}
</script>

<style lang="scss" scoped>
.tags {
  background: white;
  font-size: 16px;
  h3 {
    padding: 10px 0;
    text-align: center;
    font-weight: 400;
    border-bottom: 1px solid #000;
  }
  .tag {
    padding-left: 16px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e6e6e6;
    span {
      display: flex;
      align-items: center;
      .icon {
        width: 30px;
        height: 30px;
        color: #333;
      }
    }
    .icon {
      width: 18px;
      height: 18px;
      color: #666;
      margin-right: 16px;
    }
  }
}
.createTag-wrapper {
  text-align: center;
  padding: 16px;
  margin-top: 44-16px;
  > .icon {
    width: 50px;
    height: 50px;
  }
}
</style>

